import Vue from 'vue'
import Vuex from 'vuex'
//import userinfo from './userinfo';

Vue.use(Vuex);

export default new Vuex.Store({
  state:{
    userinfo:{
      username:'',
      account:'',
      password:'',
      avatar:1
    }
  },
  mutations:{
    USER_INFO(state,info){//
      state.userinfo.username=info.UserName
      state.userinfo.account=info.Account
      state.userinfo.password=info.Password
      state.userinfo.avatar=info.Avatar
    },
    USER_NAME(state,name){
      state.userinfo.username = name
    },
    USER_ACCOUNT(state,acc){
      state.userinfo.account = acc
    },
    USER_PASSWORD(state,pwd){
      state.userinfo.password = pwd
    },
    USER_AVATAR(state,ava){
      state.userinfo.avatar = ava
    },
  },
  actions:{
    saveUserInfo({ commit },data){
      commit('USER_INFO',data)
    },
    saveUsername({ commit },data){
      commit('USER_NAME',data)
    },
    savePassword({ commit },data){
      commit('USER_PASSWORD',data)
    },
    saveAccount({ commit },data){
      commit('USER_ACCOUNT',data)
    },
    saveAvatar({ commit },data){
      commit('USER_AVATAR',data)
    },
  }
});
